package com.infoauto.opc.gateway.opc.model;

import lombok.Getter;
import lombok.Setter;

import java.util.Map;

/**
 * 配置接口实体
 * */
@Getter
@Setter
public class MqttInterface {
    private int interfaceID;
    private String labelName;
    private String interfaceName;
    private String labelValue;
    private String description;
    private Map<Integer, MqttInterfaceNode> nodes;

    /**
     * 接口数据生成json格式
     * **/
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{\"labelName\":\"");
        sb.append(this.labelName);
        sb.append("\",\"Label\":\"");
        sb.append(this.labelValue);
        sb.append("\",\"InterfaceName\":\"");
        sb.append(this.interfaceName);
        sb.append("\",\"Values\":{");
        for(MqttInterfaceNode in:nodes.values()){
            sb.append(in.toString());
            sb.append(",");
        }
        if (nodes.size()>0)
        {
            sb = sb.deleteCharAt(sb.length()-1);
        }
        sb.append("}}");
        return  sb.toString();
    }
}
